package smetana.modules.ui.form.window;

import com.google.inject.Inject;
import org.apache.pivot.wtk.CardPane;
import org.apache.pivot.wtkx.WTKX;
import smetana.modules.ui.form.AbstractPanel;
import smetana.modules.ui.form.doc.DocEditPanel;
import smetana.modules.ui.form.doc.DocListPanel;

/**
 *
 * @author dmitry.mamonov
 */
public class WorkPanel extends AbstractPanel {
    @WTKX
    CardPane cardPaneWork;
    @Inject
    DocListPanel docListPanel;
    @Inject
    DocEditPanel docEditPanel;

    public WorkPanel() {
        super();
    }

    @Override
    public void init() {
        cardPaneWork.add(docListPanel.getComponent());
        cardPaneWork.add(docEditPanel.getComponent());
    }

    public void switchToDocumentsList(){
        int index = cardPaneWork.indexOf(docListPanel.getComponent());
        cardPaneWork.setSelectedIndex(index);
    }

    public void switchToDocumentEdit(){
        int index = cardPaneWork.indexOf(docEditPanel.getComponent());
        cardPaneWork.setSelectedIndex(index);
    }
}
